#include "DateTimeTestSuite.h"
using namespace xncc::types;
TEST_F(DateTimeTestSuite, ShowTimeNow)
{
    DateTime dt = DateTime::nowUtc();
    std::cout << dt.toString() << std::endl;
    std::cout << dt.toStringNoFraction() << std::endl;
    std::cout << dt.toStringWithMillSecond() << std::endl;
    std::cout << dt.toStringWithMicroSecond() << std::endl;
    std::cout << dt.toStringWithNanoSecond() << std::endl;

    DateTime ldt = DateTime::nowLocal();
    std::cout << ldt.toString() << std::endl;
    std::cout << ldt.toStringNoFraction() << std::endl;
    std::cout << ldt.toStringWithMillSecond() << std::endl;
    std::cout << ldt.toStringWithMicroSecond() << std::endl;
    std::cout << ldt.toStringWithNanoSecond() << std::endl;
}
TEST_F(DateTimeTestSuite, ShowLocalTimeNow)
{
    LocalTimeStamp ldt;
    std::cout << ldt.toString() << std::endl;
    std::cout << ldt.toStringNoFraction() << std::endl;
    std::cout << ldt.toStringWithMillSecond() << std::endl;
    std::cout << ldt.toStringWithMicroSecond() << std::endl;
    std::cout << ldt.toStringWithNanoSecond() << std::endl;
}

TEST_F(DateTimeTestSuite, ShowUTCTimeNow)
{
    UtcTimeStamp dt;
    std::cout << dt.toString() << std::endl;
    std::cout << dt.toStringNoFraction() << std::endl;
    std::cout << dt.toStringWithMillSecond() << std::endl;
    std::cout << dt.toStringWithMicroSecond() << std::endl;
    std::cout << dt.toStringWithNanoSecond() << std::endl;
}

TEST_F(DateTimeTestSuite, Convert1)
{
    UtcTimeStamp dt;
    std::cout << dt.toStringWithNanoSecond() << std::endl;
    LocalTimeStamp ldt = dt.toLocal();
    std::cout << ldt.toString() << std::endl;
    std::cout << ldt.toStringNoFraction() << std::endl;
    std::cout << ldt.toStringWithMillSecond() << std::endl;
    std::cout << ldt.toStringWithMicroSecond() << std::endl;
    std::cout << ldt.toStringWithNanoSecond() << std::endl;
}

TEST_F(DateTimeTestSuite, Convert2)
{
    LocalTimeStamp ldt;
    std::cout << ldt.toStringWithNanoSecond() << std::endl;
    UtcTimeStamp dt = ldt.toUtc();
    std::cout << dt.toString() << std::endl;
    std::cout << dt.toStringNoFraction() << std::endl;
    std::cout << dt.toStringWithMillSecond() << std::endl;
    std::cout << dt.toStringWithMicroSecond() << std::endl;
    std::cout << dt.toStringWithNanoSecond() << std::endl;
}

TEST_F(DateTimeTestSuite, Convert3)
{
    std::string  utc_time = "2022-01-04_12:01:12.919";
    UtcTimeStamp dt;
    auto         ret = UtcTimeStamp::convert(utc_time, dt);
    EXPECT_EQ(ret, 0);
    EXPECT_EQ(utc_time, dt.toString());
}

TEST_F(DateTimeTestSuite, Convert4)
{
    std::string    local_time = "2022-01-04_12:01:12.919";
    LocalTimeStamp dt;
    auto           ret = LocalTimeStamp::convert(local_time, dt);
    EXPECT_EQ(ret, 0);
    EXPECT_EQ(local_time, dt.toString());
}

TEST_F(DateTimeTestSuite, Convert5)
{
    std::string    local_time = "2022-01-04_12:01:12.919";
    LocalTimeStamp dt;
    auto           ret = LocalTimeStamp::convert(local_time, dt);
    EXPECT_EQ(ret, 0);
    EXPECT_EQ(local_time, dt.toString());
}